﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using QuocTeViet.DO;
using QuocTeViet.BL;

namespace QuocTeViet.AdminCP.PageUC
{
    public partial class ucListDoiTac : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            load();
        }
        public void load()
        {
            gvDT.DataSource = new cmsDoiTacBL().SelectAll();
            gvDT.DataBind();
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Response.Redirect("Default.aspx?Page=DoiTac");
        }

        protected void gvDT_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvDT.PageIndex = e.NewPageIndex;
            load();
        }

        protected void gvDT_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            new cmsDoiTacBL().Delete(new cmsDoiTacDO { DoiTacID = Convert.ToInt32(gvDT.DataKeys[e.RowIndex].Value) });
            Functions.Alert("Xóa bản tin thành công!", Request.Url.ToString());
        }

        protected void gvDT_SelectedIndexChanged(object sender, EventArgs e)
        {
            int DoiTacID = int.Parse(gvDT.DataKeys[gvDT.SelectedIndex].Value.ToString());
            Response.Redirect("Default.aspx?Page=DoiTac&IDDT=" + DoiTacID.ToString());
        }
    }
}